package net.jgrm.order.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
@TableName("t_order")
public class Order {

    @TableId(type = IdType.AUTO)
    private Long id;

    @TableField("user_id")
    private Long userId;

    @TableField("order_no")
    private String orderNo;

    @TableField("total_amount")
    private BigDecimal totalAmount;

    @TableField("status")
    private Integer status; // 0-待支付, 1-已支付, 2-已取消
    
    @TableField("transaction_id")
    private String transactionId; // 交易流水号
    
    @TableField("payment_time")
    private LocalDateTime paymentTime; // 支付时间

    // 收货人信息（使用PostgreSQL pgcrypto原生加密）

    @TableField("receiver_name")
    private String receiverName;
    @TableField("receiver_phone")
    private String receiverPhone;
    @TableField("receiver_phone_prefix")
    private String receiverPhonePrefix; // 手机号前3位（用于前缀查询）
    @TableField("receiver_phone_suffix")
    private String receiverPhoneSuffix; // 手机号后4位（用于后缀查询）
    @TableField("receiver_name_hash")
    private String receiverNameHash; // 姓名确定性加密哈希（用于索引查询）
    @TableField("receiver_phone_hash")
    private String receiverPhoneHash;// 手机号确定性加密哈希（用于索引查询）
    @TableField("receiver_province")
    private String receiverProvince; // 收货省份
    @TableField("receiver_city")
    private String receiverCity;     // 收货城市
    @TableField("receiver_district")
    private String receiverDistrict; // 收货区/县
    @TableField("receiver_address")
    private String receiverAddress;  // 详细收货地址

    @TableField("create_time")
    private LocalDateTime createTime;

    @TableField("update_time")
    private LocalDateTime updateTime;
}
